/**
 * @param {string[]} strs
 * @return {string[][]}
 * 输入: strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
 * 输出: [["bat"],["nat","tan"],["ate","eat","tea"]]
 */
var groupAnagrams = function(strs) {
    const map = new Map()
    let len = strs.length
    for(let i = 0;i<len;i++){
        const str = Array.from(strs[i])
        const str1 = str.sort().toString()
        const item = map.get(str1)
        if(item!==undefined){
            item.push(strs[i])
        }else{
            map.set(str1,[strs[i]])
        }
    }
    return Array.from(map.values())
};

groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"])